﻿using System;
using System.Collections.Generic;
using HK.Core.Common.Data;
using HK.Core.Common.Protocol;
using HK.Core.Common.Protocol.Data;
using HK.Core.Settings.Data;

namespace HK.Core.Settings.Protocol
{
    /// <summary>
    /// 服务器类型
    /// </summary>
    public enum ServerType
    {
        /// <summary>
        /// 开发服
        /// </summary>
        Dev,
        
        /// <summary>
        /// 测试服务
        /// </summary>
        Test,
        
        /// <summary>
        /// 正式服
        /// </summary>
        Online
    }
    
    /// <summary>
    /// 接口 : 服务器设定数据
    /// </summary>
    public interface IServerSettingsData : IListElement
    {
        /// <summary>
        /// 服务器Id
        /// <para>* 唯一标识Id</para>
        /// </summary>
        string ServerId { get; }
        
        /// <summary>
        /// 服务器类型
        /// </summary>
        ServerType Type { get; }
        
        /// <summary>
        /// 地址
        /// </summary>
        string Address { get; }
        
        /// <summary>
        /// 端口
        /// </summary>
        int Port { get; }
        
        /// <summary>
        /// 登录端口
        /// </summary>
        int LoginPort { get; }

#region Connect
        
        /// <summary>
        /// 已链接
        /// </summary>
        bool Connected { get; }

        /// <summary>
        /// 链接
        /// </summary>
        void Connect();

        /// <summary>
        /// 断开链接
        /// </summary>
        void Disconnect();
        
#endregion
        
    }

    /// <summary>
    /// 接口 : 服务器列表
    /// </summary>
    public interface IServersSettingsData<TServer> : IListJsonData<TServer>
        where TServer : JsonData, IServerSettingsData, IEquatable<TServer>
    {
        
        /// <summary>
        /// 当前服务器
        /// <para>* 既当前连接中的服务器</para>
        /// </summary>
        TServer CurServer { get; }
        
        /// <summary>
        /// 切换服务器
        /// </summary>
        /// <param name="iServerId">服务器Id</param>
        /// <returns>true:切换失败; false:切换成功;</returns>
        bool SwitchServer(string iServerId);
    }
    
    /// <summary>
    /// 接口 : 服务器列表
    /// </summary>
    public interface IServersSettingsData : IServersSettingsData<ServerSettingsData> { }
    
}